<!-- 主容器 -->
<%
  // 从metadata中获取总字数和阅读时间
  let totalWords = 0;
  let totalReadTime = 0;
  let hasStats = false;
  articles.forEach(article => {
    if (article.metadata && typeof article.metadata.wordCount === 'number' && typeof article.metadata.readTime === 'number') {
      totalWords += article.metadata.wordCount;
      totalReadTime += article.metadata.readTime;
      hasStats = true;
    }
  });
%>
<div style="
    margin: 0 12px;
    padding: 16px 0;
    font-family: -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    line-height: 1.6;
    color: #333333;
    background: #ffffff;
  ">
  <!-- 目录部分 -->
  <div style="
      margin: 20px 8px 32px;
      padding: 24px;
      background: linear-gradient(135deg, #f0f9eb, #e6f4e6);
      border-radius: 12px;
      border: 1px solid #e8f5e9;
    ">
    <% if (hasStats) { %>
    <!-- 信息统计模块 -->
    <div style="
          margin-bottom: 24px;
          padding: 16px;
          background: #ffffff;
          border-radius: 8px;
          box-shadow: 0 2px 8px rgba(0,0,0,0.03);
        ">
      <div style="
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 12px;
          ">
        <div style="
              display: flex;
              align-items: center;
              color: #4caf50;
            ">
          <svg width="20" height="20" viewBox="0 0 24 24" fill="none" style="margin-right: 8px;">
            <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm1-13h-2v6h2V7zm0 8h-2v2h2v-2z" fill="currentColor"/>
          </svg>
          <span style="font-size: 14px; font-weight: 500;">阅读指南</span>
        </div>
        <div style="
              font-size: 12px;
              color: #666;
            ">
          更新时间：今天的日期
        </div>
      </div>
      <div style="
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 12px;
          ">
        <div style="
              padding: 12px;
              background: #f5faf6;
              border-radius: 6px;
              text-align: center;
            ">
          <div style="
                font-size: 12px;
                color: #666;
                margin-bottom: 4px;
              ">
            总字数
          </div>
          <div style="
                font-size: 16px;
                color: #4caf50;
                font-weight: 500;
              ">
            <%= totalWords %> 字
          </div>
        </div>
        <div style="
              padding: 12px;
              background: #f5faf6;
              border-radius: 6px;
              text-align: center;
            ">
          <div style="
                font-size: 12px;
                color: #666;
                margin-bottom: 4px;
              ">
            预计阅读
          </div>
          <div style="
                font-size: 16px;
                color: #4caf50;
                font-weight: 500;
              ">
            <%= totalReadTime %> 分钟
          </div>
        </div>
      </div>
    </div>
    <% } %>

    <!-- 目录列表 -->
    <div style="
          margin-bottom: 16px;
          padding-bottom: 12px;
          border-bottom: 1px solid #e8f5e9;
          color: #262626;
          font-size: 16px;
          font-weight: 600;
          display: flex;
          align-items: center;
        ">
      <svg width="20" height="20" viewBox="0 0 24 24" fill="none" style="margin-right: 8px;">
        <path d="M3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7 7v2h14V7H7z" fill="#4caf50"/>
      </svg>
      文章目录
    </div>

    <% for(var i=0; i<articles.length; i++) { var article=articles[i]; %>
      <div style="
              margin: 8px 0;
              padding: 12px 16px;
              background: #ffffff;
              border-radius: 8px;
              border-left: 4px solid #e8f5e9;
              transition: all 0.2s ease;
              cursor: pointer;
            " onmouseover="this.style.borderLeftColor='#4caf50'" onmouseout="this.style.borderLeftColor='#e8f5e9'">
        <div style="
                  display: flex;
                  align-items: center;
                ">
          <div style="
                    width: 24px;
                    height: 24px;
                    border-radius: 50%;
                    background: #f0f9eb;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    margin-right: 12px;
                    color: #4caf50;
                    font-size: 12px;
                    font-weight: 500;
                  ">
            <%= i + 1 %>
          </div>
          <div style="
                    color: #262626;
                    font-size: 14px;
                    font-weight: 500;
                    line-height: 1.5;
                  ">
            <%= article.title %>
          </div>
        </div>
      </div>
      <% } %>
  </div>

  <!-- 文章内容部分 -->
  <% for(var j=0; j<articles.length; j++) { var article=articles[j]; %>
    <!-- 文章前分隔符 -->
    <div style="
          margin: 40px auto;
          text-align: center;
          color: #e0e0e0;
          position: relative;
          height: 1px;
        ">
      <div style="
            position: absolute;
            top: 50%;
            left: 0;
            right: 0;
            height: 1px;
            background: linear-gradient(90deg, transparent, #e0e0e0, transparent);
          "></div>
      <div style="
            position: relative;
            display: inline-block;
            padding: 0 16px;
            background: white;
            color: #4caf50;
            font-size: 14px;
          ">
        <svg width="16" height="16" viewBox="0 0 24 24" fill="none" style="vertical-align: middle;">
          <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm1-13h-2v6h2V7zm0 8h-2v2h2v-2z" fill="currentColor"/>
        </svg>
      </div>
    </div>

    <div style="margin: 40px 8px;">
      <!-- 文章头部 -->
      <div style="margin-bottom: 32px;">
        <!-- 编号 -->
        <div style="
                  margin-bottom: 16px;
                  color: #8c8c8c;
                  font-size: 14px;
                  letter-spacing: 0.5px;
                ">
          <%= (j + 1).toString().padStart(2, '0' ) %> / <%= articles.length.toString().padStart(2, '0' ) %>
        </div>

        <!-- 标题 -->
        <div style="
                  font-size: 22px;
                  font-weight: 600;
                  color: #262626;
                  margin-bottom: 12px;
                  line-height: 1.4;
                  letter-spacing: 0.5px;
                  position: relative;
                  padding-left: 24px;
                ">
          <div style="
                    position: absolute;
                    left: 0;
                    top: 0;
                    bottom: 0;
                    width: 4px;
                    background: #4caf50;
                    border-radius: 2px;
                  "></div>
          <%= article.title %>
        </div>

        <!-- 发布日期 -->
        <div style="
                  color: #8c8c8c;
                  font-size: 14px;
                  padding-bottom: 16px;
                  border-bottom: 1px solid #f0f0f0;
                ">
          <%= article.publishDate %>
        </div>
      </div>

      <!-- 文章内容 -->
      <div style="
              padding: 0 12px;
            ">
        <% var content=article.content || "" ; var paragraphs=content.split("<next_paragraph />");
        for(var i=0; i<paragraphs.length; i++) { var para=paragraphs[i].trim(); if(para.length> 0) {
          %>
          <p style="
                      margin: 0 0 20px;
                      color: #595959;
                      font-size: 16px;
                      line-height: 1.8;
                      text-align: justify;
                    "><%- para %></p>
          <% }} %>
      </div>
    </div>

    <!-- 文章分隔 -->
    <% if (j < articles.length - 1) { %>
      <div style="
              margin: 48px auto;
              text-align: center;
              color: #bfbfbf;
              font-size: 13px;
            ">
        * * *
      </div>
      <% } %>
        <% } %>
</div>